<?php
	$authedUser = $session->read('Auth.User');
	echo $form->create('ListingAsset', array('url'=>'/'.$this->params['url']['url'],"enctype"=>"multipart/form-data",'id'=>'listing_asset_add_form'));?>
	
	<?php 
		if(cr('ListingConfig.guest_upload_photo') == 1 && empty($authedUser))
		{
			$guestFields = cri('Users.Guest')->getFields('group', 'add');
			foreach($guestFields as $field)
			{
				echo $form->input('Guest.'.$field);
			}
		}
		//fake call initialize ListingAssetwModel in form helper.
		echo $form->input('ListingAsset.fake',array('type'=>'hidden'));
		
	?>
	<?php
		echo $form->hidden('listing_id',array('value'=>$item_id));
		echo $form->input('name', array('type'=>'file','label'=>__('Upload Image')));
		echo $form->hidden('type',array('value'=>$type));
		echo $form->end(__('Submit'));
	?>

<script type="text/javascript" src="/cms/js/jquery.validate.min.js"></script>
<script type='text/javascript'>
$(document).ready(function()
{
	$('#GuestName').parent('div').addClass('required');
	$('#GuestEmail').parent('div').addClass('required');
	
	$('.submit').live('click',function(e)
	{		
		if($("#listing_asset_add_form").valid()==false)
		{
			return;
		}
	});
});
</script>